package cn.leestudio.springboot.service;

import cn.leestudio.springboot.dao.leestudio.UserMapper;
import cn.leestudio.springboot.dao.leestudio.UserMapperExt;
import cn.leestudio.springboot.dao.study.AdminUserMapper;
import cn.leestudio.springboot.model.AdminUser;
import cn.leestudio.springboot.model.User;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * Created by Administrator on 2018/3/6.
 */
@Component
public class CommonService {

    @Autowired
    private AdminUserMapper adminUserMapper;

    @Autowired
    private UserMapperExt userMapper;

//    @Autowired
//    private RedisTemplate stringRedisTemplate;


    public void getTest(){
        User user = userMapper.selectByPrimaryKey(1);
        System.out.println("user -> "+user.getFirstname());
        AdminUser adminUser = adminUserMapper.selectByPrimaryKey(1);
        System.out.println("adminUser -> "+adminUser.getUsername());
    }

    public void getPageTest(){
        PageHelper.offsetPage(1, 5,true);
        List<User> list = (List<User>) userMapper.selectByPage();
        PageInfo pageInfo = new PageInfo(list);
        System.out.println("pageInfo -> "+pageInfo.toString());
        System.out.println("List<User> -> "+list.size());
        for (User user : list){
            System.out.println("     -> "+user.getFirstname());
        }

    }

}
